﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;

public class ToggleGroupCtrl : MonoBehaviour, IToggleGroupCtrl
{
    [SerializeField]
    private ToggleGroup togglegroup;

    [SerializeField]
    public Toggle[] toggles;

    public void Start()
    {
    }

    public void AddListen(OnToggleGroupCtrlChanged change)
    {
        Debug.Log("ToggleGroupCtrl.AddListen Change: " + change);

        foreach (Toggle toggle in toggles)
        {
            Debug.Log(toggle.name + " : " + change);

            //togglegroup.RegisterToggle(toggle);

            toggle.onValueChanged.AddListener((value) =>
            {
                change(toggle.name, value);
            });
        }
    }
}
